//
//  GYMainTabBarController.m
//  Visitor
//
//  Created by x on 2017/9/12.
//  Copyright © 2017年 HLB. All rights reserved.
//

#import "GYMainTabBarController.h"
#import "GYBaseNavigationController.h"
@interface GYMainTabBarController ()

@end

@implementation GYMainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //1.初始化子控制器
    [self setupChildViewControllers];
}


- (void)setupChildViewControllers {
    
    [self addchildViewController:@"home_icon_visitor_nor" HightImage:@"home_icon_visitor_sel" viewControllerName:@"GYVisitorViewController" title:@"访客"];
    [self addchildViewController:@"home_icon_my_nor" HightImage:@"home_icon_my_sel" viewControllerName:@"GYMyViewController" title:@"我的"];
}

/**
 创建一个子控制器

 @param imageName 图片
 @param hightimage 高亮图片
 @param viewControllerName 控制器字符串名字
 @param title 标题
 */
- (void)addchildViewController:(NSString *)imageName HightImage:(NSString *)hightimage viewControllerName:(NSString *)viewControllerName title:(NSString *)title {
    
    //1.首先字符串转换成类
    Class class =  NSClassFromString(viewControllerName);
    UIViewController *viewController = [[class alloc] init];
    viewController.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    viewController.tabBarItem.selectedImage = [[UIImage imageNamed:hightimage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    viewController.tabBarItem.title = title;
    
    GYBaseNavigationController *baseNavi = [[GYBaseNavigationController alloc] initWithRootViewController:viewController];
    
    [self addChildViewController:baseNavi];
}
@end
